catch
Type
keyword
Summary
Used within a try control structure to handle errors.
Syntax
catch <errorParameter>
Description
Use the catch keyword to handle errors returned by a handler with the throw control structure.
When one of the statements in a try control structure causes an execution error, the errorParameter is set to the error string, and the statements after the catch keyword are executed. If LiveCode generates the error (for example, an execution error from a built-in command), the errorParameter is a positive number. An error string can also be returned from a handler by the throw keyword.
The statements after the catch keyword are only executed if there is an error. These statements can refer to the value of the errorParameter. For example, the catch section might contain an if or switch control structure, which does different things depending on the value of the errorParameter.
Parameters
Name | Type | Description |
---|---|---|
errorParameter |
Examples
catch myError
Related
glossary: return, handle, handler, execute, error, statement, execution error, keyword, control structure, command
control structure: if, switch, try, throw
Compatibility and Support
Introduced
LiveCode 1.0
OS
mac
windows
linux
ios
android
Platforms
desktop
server
mobile